package me.monster.smarttraffic.ui.bus;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * @description
 * @author: Created jiangjiwei in 2020-02-13 15:08
 */
public class BusAdapter extends FragmentPagerAdapter {

    private List<Fragment> mFragments;

    public BusAdapter(@NonNull FragmentManager fm, List<Fragment> fragments) {
        this(fm, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
        this.mFragments = new ArrayList<>(fragments.size());
        mFragments.addAll(fragments);
    }

    public BusAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
    }


    @NonNull
    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }
}
